#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
string s;
int cnt[30][30] = {0};
int main()
{
	cin >> n >> s;
	for (int i = 0; i < n - 1; i++)
	{
		int x = s[i] - 'A', y = s[i + 1] - 'A';
		cnt[x][y]++;
		ans = max(ans, cnt[x][y]);
	}
	for (int i = 0; i < 26; i++)
	{
		for (int j = 0; j < 26; j++)
		{
			if (cnt[i][j] == ans)
			{
				cout << char('A' + i) << char('A' + j);
				return 0;
			}
		}
	}
}